import store from "../store";

const items = [
    {
        icon: "el-icon-lx-home",
        index: "/Dashboard",
        title: "系统首页",
    },
    {
        icon: "el-icon-lx-cascades",
        index: "/baseTable",
        title: "基础表格",
    },
    {
        icon: "el-icon-lx-copy",
        index: "/tabs",
        title: "tab选项卡",
    },
    {
        icon: "el-icon-lx-calendar",
        index: "3",
        title: "表单相关",
        subs: [
            {
                index: "/baseForm",
                title: "基本表单",
            },
            {
                index: "/upload",
                title: "文件上传",
            },
            {
                index: "4",
                title: "三级菜单",
                subs: [
                    {
                        index: "/editor",
                        title: "富文本编辑器",
                    },
                ],
            },
        ],
    },
    {
        icon: "el-icon-lx-emoji",
        index: "/icon",
        title: "自定义图标",
    },
    {
        icon: "el-icon-pie-chart",
        index: "/baseCharts",
        title: "schart图表",
    },
    {
        icon: "el-icon-lx-global",
        index: "/i18n",
        title: "国际化功能",
    },
    {
        icon: "el-icon-lx-warn",
        index: "7",
        title: "错误处理",
        subs: [
            {
                index: "/permission",
                title: "权限测试",
            },
            {
                index: "/404",
                title: "404页面",
            },
        ],
    },
];

const titleMap = new Map();
const getTitleMap = (items) => {
    for (let i = 0; i < items.length; i++) {
        titleMap.set(items[i].index.substring(1).toLowerCase(),items[i].title);
        if(items[i].subs && items[i].subs.length > 0){
            getTitleMap(items[i].subs);
        }
    }
}
getTitleMap(items);

store.state.sidebarItems = items;
store.state.titleMap = titleMap;
